#include <iostream>
#include <string>
#include <vector>

size_t split(const std::string &s, const std::string step, std::vector<std::string> &result)
{
    int pos = 0, index = 0;
    while (index < s.size())
    {
        pos = s.find(step, index);
        while (pos == index)
        {
            index = pos + step.size();
            pos = s.find(step, index);
        }
        if (pos == std::string::npos)
        {
            result.push_back(s.substr(index));
            break;
        }
        result.push_back(s.substr(index, pos - index));
        index = pos + step.size();
    }
    return result.size();
}

int main()
{
    std::string s = "...news....music.#.pop...";
    std::vector<std::string> result;
    split(s, ".", result);
    for (auto &ch : result)
    {
        std::cout << ch << std::endl;
    }
    return 0;
}
